package com.gary.springcloud.call.job;

import com.gary.springcloud.call.entity.ExecutorResult;
import com.gary.springcloud.call.service.CommonService;
import com.gary.springcloud.call.task.TestCallable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author peng_rui
 * @date 2023/1/9
 */
@Slf4j
@Service
public class CallJob {

    @Autowired
    private CommonService commonService;

    @Scheduled(cron = "*/5 * * * * *")
    public void callTask() {
        log.info("call schedule task ...");
        List<ExecutorResult> executorResults = commonService.startService(TestCallable.class);
        executorResults.forEach(info -> {
            log.info("call task info result : " + info.getMsg());
        });
    }
}
